from django.db import models


# 文章表
class Essay(models.Model):
    # 文章id
    essay_id = models.AutoField(primary_key=True)
    # 发布人手机号
    phone = models.CharField(max_length=11)
    # 空间id
    space_id = models.IntegerField()
    # 文章内容
    essay_content = models.TextField()
    # 点赞数
    like_count = models.IntegerField(default=0)
    # 收藏数
    collect_count = models.IntegerField(default=0)
    # 发布时间
    create_time = models.DateTimeField(auto_now_add=True)
    # 图片地址
    essay_images = models.TextField()


# 点赞表
class Like(models.Model):
    # 点赞id
    like_id = models.AutoField(primary_key=True)
    # 点赞人手机号
    phone = models.CharField(max_length=11)
    # 点赞文章id
    essay_id = models.IntegerField()
    # 点赞时间
    like_time = models.DateTimeField(auto_now_add=True)


# 评论表
class Comment(models.Model):
    # 评论id
    comment_id = models.AutoField(primary_key=True)
    # 评论人手机号
    phone = models.CharField(max_length=11)
    # 评论文章id
    essay_id = models.IntegerField()
    # 评论时间
    comment_time = models.DateTimeField(auto_now_add=True)
    # 评论内容
    comment_content = models.TextField()
    # 回复目标  “essay”/"user"
    reply_type = models.CharField(max_length=40)
    # 回复用户名  "essay"时为空
    reply_username = models.CharField(max_length=40)


# 收藏表
class Collect(models.Model):
    # 收藏id
    collect_id = models.AutoField(primary_key=True)
    # 收藏人手机号
    phone = models.CharField(max_length=11)
    # 收藏文章id
    essay_id = models.IntegerField()
    # 收藏时间
    collect_time = models.DateTimeField(auto_now_add=True)
